

*************************************************
*************************************************
***The Swing Justice
***Peter K. Enns and Patrick Wohlfarth
***The Journal of Politics 2013
*************************************************
*************************************************

************************
**Replication File
**This do file replicates all results reported in "The Swing Justice"
**except for the predicted probabilities. See SubstantiveEffectsCI.do and
**SubstantiveEffectsCIsMedSwingJustice.do for those replications.
************************

************************
**NOTE: Must set the working directory
************************
cd ""

************************
**Data
************************
set mem 25000k
use "swingJustice_jopFINpub.dta"




pause on

************
**The proportion of correct justice vote predictions in 5 to 4 cases based on ordinal justice positions
**(as reported in the text).
************
*Issue Specific MQ scores (8 issues)
gen correctpred_mq8 = 0 if majVote==5 & minVote==4 & mq8_order!=5
recode correctpred_mq8 0=1 if mq8_order>=1 & mq8_order<=4 & direction==2
recode correctpred_mq8 0=1 if mq8_order>=6 & mq8_order<=9 & direction==1
tab correctpred_mq8
drop correctpred_mq8

************
**Figure 1: Percent of Cases as Swing Jutice
************
gen swjust = 0 if sw_medmq8!=. & sw_notmedmq8!=.
recode swjust 0=1 if sw_medmq8==1
recode swjust 0=1 if sw_notmedmq8==1
tab justiceName swjust if majVote==5 & minVotes==4 & justiceName!="SSotomayor", row
drop swjust

**type "q" to continue do file
pause



************************************************************************************
****************************
****************************
***Justice-by-Justice Analysis
****************************
****************************
************************************************************************************


****************************
****************************
**Reversals, All
**FIGURE 2
**Note: Figure based on Average Marginal Effects
****************************
****************************


**all
egen cplib_allzallr = std(cp_reclib) if reversal==1 & totalVotes==9 & term<2008
logit libvote sgconslib mood5208  cplib_allzallr zsop_phmsm judpower economics civillib if reversal == 1 & totalVotes==9 & term<2008, cluster(term)
margeff
**sw_medmq8
egen cplib_swmed8zallr = std(cp_reclib) if reversal==1 & sw_medmq8==1 & term<2008
logit libvote sgconslib mood5208 cplib_swmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
egen cplib_swnotmed8zallr = std(cp_reclib) if reversal==1 & sw_notmedmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

**type "q" to continue do file
pause

**pos4mq8
egen cplib_pos48zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos4mq8==1, cluster(term)
margeff
**pos3mq8
egen cplib_pos38zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos3mq8==1
logit libvote sgconslib mood5208  cplib_pos38zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos3mq8==1, cluster(term)
margeff
**pos2mq8
egen cplib_pos28zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos2mq8==1
logit libvote sgconslib mood5208  cplib_pos28zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos2mq8==1, cluster(term)
margeff
**pos1mq8
egen cplib_pos18zallr = std(cp_reclib) if reversal == 1 & term<2008 & pos1mq8==1
logit libvote sgconslib mood5208  cplib_pos18zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & pos1mq8==1, cluster(term)
margeff


************
**Test of equal AME for SOP for all justice analysis and median swing justice analysis (as reported in the text).
************
logit libvote sgconslib mood5208  cplib_allzallr zsop_phmsm judpower economics civillib if reversal == 1 & totalVotes==9 & term<2008
margeff
est store ameall
logit libvote sgconslib mood5208 cplib_swmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_medmq8==1
margeff
est store amemedsj
suest ameall amemedsj, cluster(term)
**For Stata 10 and earlier:
*test [ameall]zsop_phmsm=[amemedsj]zsop_phmsm
**For Stata 11 and later:
*test [ameall_libvote]zsop_phmsm=[amemedsj_libvote]zsop_phmsm

**type "q" to continue do file
pause


***********
**Evidence of a positive relationship between SOP constraint and the votes of the ideological swing justice
**when restricting the analysis to cases of judicial review at the federal level, as reported in the text.
**As we note in the article, this result is "by no means conclusive" given the small sample size and 
**uncertainty around the estimate.
***********
drop cplib_swnotmed8zallr 
egen cplib_swnotmed8zallr = std(cp_reclib) if reversal==1 & sw_notmedmq8==1 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8zallr zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & sw_notmedmq8==1 & authorityDecision1==1 | reversal == 1 & term<2008 & sw_notmedmq8==1 & authorityDecision2==1, cluster(term)
margeff


**type "q" to continue do file
pause

****************************
**FIGURE 3 
**Reversals, 5-4 Decisions
**Note: Figure based on Average Marginal Effects
****************************

**all
egen cplib_allz54r = std(cp_reclib) if reversal==1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_allz54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008, cluster(term)
margeff
**sw_medmq8
egen cplib_swmed8z54r = std(cp_reclib) if  sw_medmq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swmed8z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_medmq8==1, cluster(term)
margeff
**sw_notmedmq8
egen cplib_swnotmed8z54r = std(cp_reclib) if sw_notmedmq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_swnotmed8z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & sw_notmedmq8==1, cluster(term)
margeff

**type "q" to continue do file
pause

**pos4mq8
egen cplib_pos48z54r = std(cp_reclib) if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq8==1
logit libvote sgconslib mood5208  cplib_pos48z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos4mq8==1, cluster(term)
margeff
**pos3mq8
egen cplib_pos38z54r = std(cp_reclib) if pos3mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos38z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos3mq8==1, cluster(term)
margeff
**pos2mq8
egen cplib_pos28z54r = std(cp_reclib) if pos2mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos28z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos2mq8==1, cluster(term)
margeff
**pos1mq8
egen cplib_pos18z54r = std(cp_reclib) if pos1mq8==1 & reversal == 1 & majVote==5 & minVote==4 & term<2008
logit libvote sgconslib mood5208  cplib_pos18z54r  judpower economics civillib zsop_phmsm if reversal == 1 & majVote==5 & minVote==4 & term<2008 & pos1mq8==1, cluster(term)
margeff

**type "q" to continue do file
pause
*************************************
**Interaction between justice position and ideology, as reported in the text
*************************************

*Note: ideological swing justice excluded because would exagerate ideological difference b/t swing justice and other positions
gen justpos = .
recode justpos .=0 if sw_medmq8==1
recode justpos .=1 if pos4mq8==1
recode justpos .=2 if pos3mq8==1
recode justpos .=3 if pos2mq8==1
recode justpos .=4 if pos1mq8==1

gen ideoXjustpos = cp_reclib*justpos


**ALL REVERSALS
logit libvote  ideoXjustpos justpos cp_reclib sgconslib mood5208  zsop_phmsm judpower economics civillib if reversal == 1 & term<2008, cluster(term)
**5-4 REVERSALS
logit libvote  ideoXjustpos justpos cp_reclib sgconslib mood5208  zsop_phmsm judpower economics civillib if reversal == 1 & term<2008 & majVote==5 & minVote==4, cluster(term)

drop justpos ideoXjustpos  cplib_allzallr cplib_swmed8zallr cplib_swnotmed8zallr cplib_pos48zallr cplib_pos38zallr cplib_pos28zallr cplib_pos18zallr _est_ameall _est_amemedsj
drop cplib_allz54r cplib_swmed8z54r cplib_swnotmed8z54r cplib_pos48z54r cplib_pos38z54r cplib_pos28z54r cplib_pos18z54r 

